package tech.lq0.dreamaticvoyage.item.fukamizutech.material;

import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.food.FoodProperties;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.Nullable;
import tech.lq0.dreamaticvoyage.init.DamageSourceRegistry;
import tech.lq0.dreamaticvoyage.init.EffectRegistry;

import java.util.List;

public class HoneyFukamizuBread extends Item {

    public static final FoodProperties FOOD = new FoodProperties.Builder().nutrition(10).saturationMod(0.8f).alwaysEat()
            .effect(() -> new MobEffectInstance(MobEffects.REGENERATION, 600, 0), 1.0f)
            .effect(() -> new MobEffectInstance(EffectRegistry.BLEEDING.get(), 200, 0), 0.2f)
            .build();

    public HoneyFukamizuBread() {
        super(new Properties().fireResistant().food(FOOD));
    }

    @Override
    public void appendHoverText(ItemStack pStack, @Nullable Level pLevel, List<Component> pTooltipComponents, TooltipFlag pIsAdvanced) {
        pTooltipComponents.add(Component.translatable("des.dreamaticvoyage.honey_fukamizu_bread").withStyle(ChatFormatting.GRAY));
    }

    @Override
    public ItemStack finishUsingItem(ItemStack pStack, Level pLevel, LivingEntity pLivingEntity) {
        if (!pLevel.isClientSide) {
            pLivingEntity.hurt(DamageSourceRegistry.causeFukamizuBreadDamage(pLevel.registryAccess(), null), 10.0f);
        }
        return super.finishUsingItem(pStack, pLevel, pLivingEntity);
    }
}
